﻿
namespace tcom.tools
{
	using UnityEngine;
	using System.Collections;
	using System.Collections.Generic;
	using System;
	using System.IO;
	
	/// <summary>
	/// T timer.
	/// </summary>
	public class TTimer {
	
		public float curtime;
		public float fTime;
		
		public TTimer()
		{
			fTime = 1.0f;
			curtime = 1.0f;
		}
		
		public TTimer(float time)
		{
			fTime = time;
			curtime = 0;
		}
		
		public void SetTime(float time)
		{
			fTime = time;
			curtime = 0;
		}
	
		public void Update(float deltaTime)
		{
			curtime += deltaTime;
		}
		
		public void Clear()
		{
			curtime = fTime;
		}
		
		public bool IsReady()
		{
			return End();
		}
		
		public bool End()
		{
			return curtime >= fTime;
		}
		
		public void Reset()
		{
			curtime = 0;
		}
		
		public float GetPercent()
		{
			return Mathf.Max(0, Mathf.Min(curtime / fTime, 1.0f));
		}
	}
	
	
	public static class ColorExtensions
	{
		public static Color ParseColor(string col)
		{
			string[] strings = col.Split(","[0]);
			
			Color output = new Color();
			for(var i = 0; i < 4; i++)
			{
				output[i] = Convert.ToSingle(strings[i]);
			}
			return output;
		}
	}
	
	
	
	
}


